package com.zyh.thread;

/**
 * @Author zyh
 * @Date 2024/8/7 15:50
 * @Description 设置优先级
 */

public class ThreadDemo5 {
    public static void main(String[] args) {

        MyTask02 myTask02 = new MyTask02();
        Thread t1 = new Thread(myTask02, "线程A");
        t1.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        Thread t2 = new Thread(myTask02, "----线程B");
        t2.setPriority(Thread.MIN_PRIORITY);
        t2.start();
    }
}

class MyTask02 implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + "正在打印" + i);
        }
    }
}
